/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package Sequential;

import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;

/**
 *
 * @author zwirek
 */
public class StringPool {
  static private ConcurrentMap<String,String> map;

  public static String getCanonicalVersion(String str) {
    if(map==null){
        map = new ConcurrentHashMap<String,String>(1000);
    }
    String canon = map.putIfAbsent(str, str);
    return (canon == null) ? str : canon;
  }
}

